home *** CD-ROM | disk | FTP | other *** search
/ The Games Machine 76 / XENIATGM66.iso / Indiana Jones / Indiana Jones.exe / RESOURCE / PREVIEW.GOB / cog_class_mcheadbonk.cog < prev    next >
Text File  |  1999-11-15  |  2KB  |  101 lines

  1. # Jones 3D Cog Script
  2. #
  3. # class_mcheadbonk.cog
  4. #
  5. # [SCHOLL]
  6. #
  7. # (C) 1999 LucasArts Entertainment Company LLC. All Rights Reserved
  8. #
  9. # ===================================================================
  10.  
  11. symbols
  12.  
  13. message     touched
  14. message        pulse
  15.  
  16. # ************************** TEMPLATE *******************
  17.  
  18. sound        bonk=sol_minecar_head_bonk_c.wav local
  19. keyframe    hithead=im_hithead.key                local
  20. keyframe    hitheadbw=im_hithead_backwards.key    local 
  21.  
  22. # ************************** MISC LOCAL VARS *******************
  23. thing        t_Player    local
  24. int            semaphore=0    local
  25. vector        v_PlayerVel local
  26. vector        v_PlayerLook local
  27. vector        v_HeadPYR    local        
  28. flex        f_Dot        local
  29. flex        f_Pitch        local
  30. flex        f_VelMag    local 
  31. flex        f_Damage    local
  32. flex        f_Sleep        local
  33.  
  34. end
  35.  
  36. # ===================================================================
  37.  
  38. code
  39.  
  40. # ...................................................................
  41. touched:
  42.     t_Player = GetLocalPlayerThing();
  43.  
  44.     if ( GetSourceRef() == t_Player 
  45.          && BITTEST(GetPhysicsFlags(t_Player), 0x1000000) // must be mine car
  46.          && !IsCrouching(t_Player)
  47.          && !semaphore)
  48.     {
  49.         v_PlayerVel = GetThingVel(t_Player);
  50.         f_VelMag = VectorLen(v_PlayerVel);
  51.         f_Damage = 277.775 * f_VelMag;   # was 70
  52.  
  53.         DamageThing(t_Player, f_Damage, 0x04000000, GetSenderRef());
  54.         PlaySoundThing(bonk, t_Player, 1.0, 10.0, 20.0, 0x880);
  55.         
  56.         v_PlayerLook = GetThingLVec(t_Player);
  57.         f_Dot = VectorDot(v_PlayerLook, v_PlayerVel);
  58.         if (f_Dot >= 0.0)
  59.         {
  60.             PlayKey(t_Player, hithead, 8, 0x2, 0 );
  61.         }
  62.         else
  63.         {
  64.             PlayKey(t_Player, hitheadbw, 8, 0x2, 0 );
  65.         }
  66.  
  67.         // Sleep briefly with semphore set to avoid bonking
  68.         // head on same pipe several times.
  69.         // The slower Indy is going the longer the sleep
  70.         semaphore=1;
  71.         f_Sleep = 1.8 - f_VelMag;
  72.         if (f_VelMag <= 0.0 )
  73.         {
  74.             f_Sleep = 0.25;
  75.         }
  76.         Sleep(f_Sleep); 
  77.         semaphore=0;
  78.     }
  79.  
  80.     return;
  81.  
  82. # ...................................................................
  83.  
  84. pulse:
  85.     t_Player = GetLocalPlayerThing();
  86.     v_HeadPYR = GetActorHeadPYR(t_Player);
  87.     f_Pitch = VectorX(v_HeadPYR);
  88.     f_Pitch = f_Pitch * 0.75;
  89.     if (ABS(f_Pitch) <= 1.0)
  90.     {
  91.         f_Pitch = 0.0;
  92.         SetPulse(0.0);
  93.     }
  94.     v_HeadPYR = VectorSet(f_Pitch, VectorY(v_HeadPYR), VectorZ(v_HeadPYR));
  95.     SetActorHeadPYR(t_Player, v_HeadPYR);
  96.  
  97.     return;
  98.  
  99. end
  100.  
  101.